#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "qextserialport.h"
#include "serialportmanager.h"
#include "canmessage.h"
#include "fakecharger.h"
#include "faketemperaturemodule.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    enum ChargerStates
    {
        NOT_CONNECTED,
        CHARGING_NORMAL,
        CHARGE_COMPLETE,
        INTERNAL_TOO_COLD,
        INTERNAL_MISSING_SENSOR,
        OTHER_TOO_COLD,
        OTHER_MISSING_SENSOR,
        NOT_CONFIGURED_AS_MASTER = 0xff
    };

    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    
    static QString ConvertChargeStateEnumToText(ChargerStates state);
public slots:
    void ButtonPressed();
    void LineRecieved();
    void ClearChargeStateMessages();
    void UpdateFakeTemp();
    void UpdateSecondaryFakeTemp();

private:
    Ui::MainWindow *ui;
    SerialPortManager portManager;
    FakeCharger Charger;
    FakeTemperatureModule TempModule;
    FakeTemperatureModule SecondaryTempModule;

    void ParseChargeCommand(CanMessage mess);
    void ParseTemperatureStatus(CanMessage mess);
    void HandleTabStuff(CanMessage &mess);
};

#endif // MAINWINDOW_H
